import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import path from 'path'

export default defineConfig({
  plugins: [react()],
  server: {
    proxy: {
      // 代理所有请求到 http://localhost:3000
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,               // 修改请求头中的 Origin
        rewrite: (path) => path.replace(/^\/api/, ''),  // 将 /api 前缀去掉
      },
    },
  },
  build: {
    outDir: path.resolve(__dirname, '../html'),
  },
})